home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-11-08 | 8.9 KB | 303 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWFileOp.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWFILEOP_H
- #define FWFILEOP_H
-
-
- // ----- OS Includes -----
-
- #ifndef FWFILESP_H
- #include "FWFileSp.h"
- #endif
-
- // ----- Foundation Includes -----
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- //----- Macintosh includes -----
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__FILES__)
- #include <Files.h>
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__STANDARDFILE__)
- #include <StandardFile.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CWindow;
-
- //========================================================================================
- // CLASS FW_COpenFileParameters - parameters for StandardGetFile (Mac) and GetOpenFileName (Windows)
- //========================================================================================
-
- class FW_CLASS_ATTR FW_COpenFileParameters FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_COpenFileParameters();
- virtual ~ FW_COpenFileParameters();
-
- #ifdef FW_BUILD_MAC
- FW_COpenFileParameters(OSType* fileType,
- FileFilterProcPtr fileFilterProc);
- // Use when there's only one file type
-
- FW_COpenFileParameters(short numTypes,
- OSType* fileType,
- FileFilterProcPtr fileFilterProc);
- // Use for 2-4 file types
-
- void Set(short numTypes,
- OSType *fileType,
- FileFilterProcPtr fileFilterProc);
-
- short MacCountTypes() const;
- FileFilterProcPtr MacGetFilterProc() const;
- OSType* GetTypes() const;
-
- private:
- short fNumTypes;
- OSType fTypes[4];
- FileFilterProcPtr fFileFilterProc;
- #endif
-
- #ifdef FW_BUILD_WIN
- FW_COpenFileParameters(const FW_CString& filterString,
- const FW_CString& defaultExt,
- HWND ownerWindow = NULL);
-
- void Set(const FW_CString& filterString,
- const FW_CString& defaultExt);
-
- char* WinGetFilterString() const;
- char* WinGetDefaultExt() const;
- HWND WinGetOwnerWindow() const;
-
- private:
- HWND fOwnerWindow; // [KVV] Windows-specific data type! Temporary!
- char* fFilterString;
- char fDefaultExt[4];
- #endif
-
- };
-
- //========================================================================================
- // CLASS FW_CSaveFileParameters - parameters for StandardPutFile (Mac) and GetSaveFileName (Windows)
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CSaveFileParameters FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CSaveFileParameters();
- ~ FW_CSaveFileParameters();
-
- #ifdef FW_BUILD_MAC
- public:
- FW_CSaveFileParameters(const FW_CString& savePrompt,
- const FW_CString& defaultName);
-
- void MacGetSavePrompt(FW_CString& savePrompt) const;
- void MacGetDefaultName(FW_CString& defaultName) const;
-
- private:
- FW_CDynamicString fSavePrompt;
- FW_CDynamicString fDefaultName;
-
- #endif
-
- #ifdef FW_BUILD_WIN
- public:
- FW_CSaveFileParameters(const FW_CString& filterString,
- const FW_CString& defaultExt,
- const FW_CString& defaultName,
- HWND ownerWindow = NULL);
-
- char* WinGetFilterString() const;
- char* WinGetDefaultExt() const;
- char* WinGetDefaultName() const;
- HWND WinGetOwnerWindow() const;
-
- private:
- void Set(const FW_CString& filterString,
- const FW_CString& defaultExt,
- const FW_CString& defaultName);
-
- HWND fOwnerWindow;
- char* fFilterString;
- char fDefaultExt[4];
- char* fDefaultName;
- #endif
-
- };
-
- //========================================================================================
- // CLASS FW_CChooseFile - choose a file to open or save
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CChooseFile
- {
- public:
- static FW_CFileSpecification* ChooseFileToOpen(const FW_COpenFileParameters& openFileParam);
-
- static FW_CFileSpecification* ChooseFileToSave(const FW_CSaveFileParameters& saveFileParam);
-
- private:
- FW_CChooseFile();
- };
-
- //========================================================================================
- // CLASS FW_COpenFileParameters inlines
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::MacCountTypes
- //----------------------------------------------------------------------------------------
- inline short FW_COpenFileParameters::MacCountTypes() const
- {
- return fNumTypes;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::MacGetFilterProc
- //----------------------------------------------------------------------------------------
- inline FileFilterProcPtr FW_COpenFileParameters::MacGetFilterProc() const
- {
- return fFileFilterProc;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::GetTypes
- //----------------------------------------------------------------------------------------
- inline OSType* FW_COpenFileParameters::GetTypes() const
- {
- return fNumTypes == -1 ? NULL : (OSType*)fTypes;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::WinGetFilterString
- //----------------------------------------------------------------------------------------
- inline char* FW_COpenFileParameters::WinGetFilterString() const
- {
- return fFilterString;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::WinGetDefaultExt
- //----------------------------------------------------------------------------------------
- inline char* FW_COpenFileParameters::WinGetDefaultExt() const
- {
- return (char*)fDefaultExt;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_COpenFileParameters::WinGetOwnerWindow
- //----------------------------------------------------------------------------------------
- inline HWND FW_COpenFileParameters::WinGetOwnerWindow() const
- {
- return fOwnerWindow;
- }
- #endif
-
- //========================================================================================
- // CLASS FW_CSaveFileParameters inlines
- //========================================================================================
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::MacGetSavePrompt
- //----------------------------------------------------------------------------------------
- inline void FW_CSaveFileParameters::MacGetSavePrompt(FW_CString& savePrompt) const
- {
- savePrompt = fSavePrompt;
- }
- #endif
-
- #ifdef FW_BUILD_MAC
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::MacGetDefaultName
- //----------------------------------------------------------------------------------------
- inline void FW_CSaveFileParameters::MacGetDefaultName(FW_CString& defaultName) const
- {
- defaultName = fDefaultName;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::WinGetFilterString
- //----------------------------------------------------------------------------------------
- inline char* FW_CSaveFileParameters::WinGetFilterString() const
- {
- return fFilterString;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::WinGetDefaultExt
- //----------------------------------------------------------------------------------------
- inline char* FW_CSaveFileParameters::WinGetDefaultExt() const
- {
- return (char*)fDefaultExt;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::WinGetDefaultName
- //----------------------------------------------------------------------------------------
- inline char* FW_CSaveFileParameters::WinGetDefaultName() const
- {
- return fDefaultName;
- }
- #endif
-
- #ifdef FW_BUILD_WIN
- //----------------------------------------------------------------------------------------
- // FW_CSaveFileParameters::WinGetOwnerWindow
- //----------------------------------------------------------------------------------------
- inline HWND FW_CSaveFileParameters::WinGetOwnerWindow() const
- {
- return fOwnerWindow;
- }
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-